package com.seventh.parkingrent.controller;


import com.seventh.parkingrent.common.Result;
import com.seventh.parkingrent.domain.CarInfo;
import com.seventh.parkingrent.service.impl.CarInfoServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Lucas
 * @since 2021-08-24
 */
@RestController
@RequestMapping("")
@CrossOrigin("*")
@Slf4j
public class CarInfoController {
    @Autowired
    private CarInfoServiceImpl carInfoService;

    @GetMapping("getcar")
    public Result getCarById(Integer id){
        log.info("获得用户id:{}",id);
        List<CarInfo> cars = carInfoService.getCarsById(id);
        return cars.size()==0?Result.fail("该用户还没有车哦"):Result.success(cars);
    }
}

